import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/login',
    method: 'POST',
    data
  })
}

export function register(data) {
  return request({
    url: '/user/register',
    method: 'POST',
    data
  })
}

export function createUser(data) {
  return request({
    url: '/user/register',
    method: 'POST',
    data
  })
}

export function updateUser(data) {
  return request({
    url: '/user/update',
    method: 'PUT',
    data
  })
}

export function deleteUser(id) {
  return request({
    url: `/user/delete/${id}`,
    method: 'DELETE'
  })
}

export function resetPassword(id) {
  return request({
    url: `/user/resetPassword/${id}`,
    method: 'PUT'
  })
}

export function changePassword(data) {
  return request({
    url: `/user/changePassword`,
    method: 'PUT',
    data
  })
}

export function changeAvatar(data) {
  return request({
    url: `/user/changeAvatar`,
    method: 'PUT',
    data
  })
}

export function getUserList(params) {
  return request({
    url: '/users',
    method: 'GET',
    params
  })
}

export function getInfo() {
  return request({
    url: '/user/info',
    method: 'GET'
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'DELETE'
  })
}
